package com.ship.control.impl;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.ModelAndView;

import com.ship.control.AbstractAdminCommandController;
import com.ship.control.search.DeptSearchCond;
import com.ship.control.search.SearchStat;
import com.ship.control.search.UserSearchCond;
import com.ship.entity.Dept;
import com.ship.entity.User;
import com.ship.service.UserService;

/**
 * 部门
 * @author wqf
 * @version  Nov 24, 2011 12:28:25 PM
 */
public class DeptListController extends AbstractAdminCommandController {

	public DeptListController(){
		this.setCommandClass(DeptSearchCond.class);
	}
	
	protected ModelAndView executeRequest(HttpServletRequest request,HttpServletResponse response,Object command)
		throws Exception{
		
		DeptSearchCond deptSearchCond=(DeptSearchCond)command;
		
		ModelAndView mav=new ModelAndView(this.view);
		deptSearchCond.setPageSize(10L);
		SearchStat searchStat=this.userService.getSearchStat(Dept.class, deptSearchCond);
		List<Dept> deptList=this.userService.getDeptList(deptSearchCond);
		mav.addObject("searchStat", searchStat);
		mav.addObject("deptSearchCond", deptSearchCond);		
		mav.addObject("deptList", deptList);
		
		return mav;
		
	}
	
	public void setUserService(UserService userService) {
		this.userService = userService;
	}

	private String view;
	private UserService userService;

	public void setView(String view) {
		this.view = view;
	}

}
